package com.boyicloud.exchangeserver.schedul


import com.alibaba.fastjson.JSON
import com.boyicloud.exchangeserver.common.Result
import com.boyicloud.exchangeserver.web.controller.WebSocketServer
import com.boyicloud.exchangeserver.web.sevice.ClientService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.scheduling.annotation.EnableScheduling
import org.springframework.scheduling.annotation.Scheduled
import org.springframework.stereotype.Component

@Component
@EnableScheduling
class SchedulingWs {

    @Autowired
    lateinit var clientService: ClientService


    @Scheduled(fixedDelay = 5000)
    fun pushList() {
        val json = JSON.toJSONString(Result(data = clientService.list()))
        WebSocketServer.sendInfo(json)
    }
}